package com.fg.pro.trade.controller;



import com.fg.pro.model.reponse.ResponseResult;
import com.fg.pro.trade.service.TradeQuotationService;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;


/**
 * 报价单(TradeQuotation)表控制层
 *
 * @author makejava
 * @since 2025-08-14 09:36:13
 */
@RestController
@RequestMapping("tradeQuotation")
public class TradeQuotationController {
    /**
     * 服务对象
     */
    @Resource
    private TradeQuotationService tradeQuotationService;

    @Operation(summary = "获取商品分页",description = "")
    @GetMapping("/getPage")
    public ResponseResult getPage(@RequestParam(required = false, defaultValue = "1") Integer pageNum,
                                  @RequestParam(required = false, defaultValue = "10") Integer pageSize){
        PageInfo pageInfo = tradeQuotationService.getPage(pageNum,pageSize);
        return ResponseResult.okResult(pageInfo);
    }

    @Operation(summary = "刷新商品",description = "参数时间，可以不传参，默认刷新时间当前")
    @PostMapping("/refresh")
    public ResponseResult refresh(@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date date) throws InterruptedException {
        boolean flag = tradeQuotationService.refresh(date);
        return ResponseResult.okResult(flag?"刷新成功":"正在刷新中。。。");
    }

}

